unit INI_NamedDevice;

interface
uses
  INI_Section;

const
  SectionNAMEDDEVICE            = 'NAMEDDEVICE';
  //MachineName                   = 'localhost:';
  KeyServerName                 = 'ServerName';
  KeyDeviceName                 = 'DeviceName';

type
  EOStandardDeviceName = (
    // logical
    sdnOD   = 19720818,
    sdnCA   = 19720819,
    sdnCD   = 19720820,
    sdnRP   = 19720821,
    sdnSC   = 19720822,
    sdnPOS  = 19720823,
    sdnUI   = 19720824,
    sdnDR   = 19720825,
    sdnDT   = 19720826,

    // physical
    sdnXOD  = 20040514,
    sdnXCA  = 20040515,
    sdnXCD  = 20040516,
    sdnXRP  = 20040517,
    sdnXSC  = 20040518,
    sdnXDR  = 20040519,
    sdnXDT  = 20040520,
    sdnXFC  = 20040521
  );

  // this record is intended only to test the uniqueness of the EOStandardDeviceName
  EOStandardDeviceNameUnique = record
    case Integer of
      Integer(sdnOD):();
      Integer(sdnCA):();
      Integer(sdnCD):();
      Integer(sdnRP):();
      Integer(sdnSC):();
      Integer(sdnPOS):();
      Integer(sdnUI):();
      Integer(sdnDR):();
      Integer(sdnDT):();

      Integer(sdnXOD):();
      Integer(sdnXCA):();
      Integer(sdnXCD):();
      Integer(sdnXRP):();
      Integer(sdnXSC):();
      Integer(sdnXDR):();
      Integer(sdnXDT):();
      Integer(sdnXFC):();
  end;

  EOIniNamedDevice = class(EOIniSection)
  private
    FDeviceName: String;

  protected
    function GetServerName: String; virtual;
    function GetDeviceName: String; virtual; abstract;

  public

    constructor Create; overload;
    constructor Create(ID: String); overload; override;

    property DeviceName: String read FDeviceName;

  end;

implementation

function EOIniNamedDevice.GetServerName: String;
begin
  Result := ReadString(KeyServerName, 'localhost');
end;

constructor EOIniNamedDevice.Create;
begin
  Inherited Create(SectionNAMEDDEVICE);

  FDeviceName := GetServerName + ':' + GetDeviceName;
end;

constructor EOIniNamedDevice.Create(ID: String);
begin
  Inherited Create(SectionNAMEDDEVICE + ID);

  FDeviceName := GetServerName + ':' + GetDeviceName;
end;

end.

